import sys

f = open(sys.argv[1])
genus = {}
for l in f.read().split("\n"):
    if len(l.split(":")) != 2: continue
    hab = l.split(":")[0].strip()
    genus[hab] = []
    spp = l.split(":")[1].strip()
    for s in spp.split(","):
        sp = s.strip().split()[0].strip()
        if sp not in genus[hab]:
            genus[hab].append(sp)
for hab in genus:
    print hab, len(genus[hab])
f.close()
